<template>
  <div id="rose-chart">
    <div class="rose-chart-title">控制分析</div>
    <dv-charts :option="option" class="pie"/>
  </div>
</template>

<script>
import { getKzfx } from "@/api/kzgl/kzfx";

export default {
  name: 'cards',
  data() {
    return {
      option: {},
      form:{}
    }
  },
  methods: {
    getlist()
    {
      const id=1;
      getKzfx(id).then(response => {
        console.log(response.data);
        this.form=response.data;
        console.log(this.form);

        let newarr=[];
        let sevm1={},sevm2={},sevm3={};

        sevm1['name']='不可控负荷'
        sevm1['value']=response.data.bkkfh;
        newarr.push(sevm1);
        sevm2['name']='可中断负荷'
        sevm2['value']=response.data.kzdfh;
        newarr.push(sevm2);
        sevm3['name']='可转移负荷'
        sevm3['value']=response.data.kzyfh;
        newarr.push(sevm3);

        console.log("newarr1",newarr)
        this.option = {
          series: [
            {
              type: 'pie',
              radius: '40%',
              roseSort: false,
              data: newarr,
              insideLabel: {
                show: false
              },
              outsideLabel: {
                formatter: '{name} {percent}%',
                labelLineEndLength: 10,
                style: {
                  fill: '#fff'
                },
                labelLineStyle: {
                  stroke: '#fff'
                }
              },
              roseType: true
            }
          ],
          color: ['#d1a216', '#4db990', '#c55942']
        }
      });
    },

  },

  mounted() {
    this.getlist();
  }
}
</script>

<style lang="less">
#rose-chart {
  width: 30%;
  height: 100%;
  margin-left: 20px;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, .5);
  box-sizing: border-box;


  .rose-chart-title {
    height: 50px;
    font-weight: bold;
    text-indent: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
  }

  .dv-charts-container {
    height: calc(~"100% - 50px");
  }

  .pie {
    margin-top: 0px;
  }
}
</style>
